package day04;

import java.util.Deque;
import java.util.LinkedList;

public class Deque2 {


    public static void main(String[] args) {
        Deque<Integer> Q=new LinkedList<>();
        for(int i=0;i<10;i++){
            if(i%2==1){
                Q.addLast(i);
            }else{
                Q.addFirst(i);
            }
        }
        System.out.println(Q);
        while(!Q.isEmpty()){
            System.out.println(Q.getFirst());
            Q.removeFirst();

        }

    }




}
